import { defineStore } from 'pinia'
import { ref } from 'vue'
import { useGetInfoService } from '@/api/user'
export const useuserStore = defineStore(
  'bigUser',
  () => {
    const token = ref('')
    const setuserToken = (newValue) => {
      token.value = newValue
    }
    const removeuserToken = () => {
      token.value = []
    }
    const userInfo = ref({})
    const setuserInfo = async () => {
      const res = await useGetInfoService()
      userInfo.value = res.data.data
    }
    const removeuserInfo = (obj) => {
      userInfo.value = obj
    }

    return {
      removeuserToken,
      setuserToken,
      token,
      userInfo,
      setuserInfo,
      removeuserInfo
    }
  },
  {
    persist: true
  }
)
